package com.superteam.zzl.adapter;

import android.content.Context;
import android.databinding.DataBindingUtil;
import android.view.View;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
import com.superteam.zzl.activity.databinding.ActivityInfoItemvpVpGvBinding;
import com.superteam.zzl.model.DynamicFragment.bean.Group;

import java.util.List;

import jp.wasabeef.glide.transformations.RoundedCornersTransformation;

/**
 * Created by Administrator on 2017/1/14.
 */

public class InfoActivityVpGvAdapter extends MyBaseAdapter<Group.DataBean.GroupListBean, InfoActivityVpGvAdapter.ViewHolder> {

    public InfoActivityVpGvAdapter(Context context, List<Group.DataBean.GroupListBean> list, int resId) {        super(context, list, resId);
    }

    @Override
    public ViewHolder bindView(View convertView, List<Group.DataBean.GroupListBean> list, int position) {
        return new ViewHolder(convertView);
    }

    @Override
    public void bindData(ViewHolder viewHolder, List<Group.DataBean.GroupListBean> list, int position) {
        ActivityInfoItemvpVpGvBinding gvBinding = viewHolder.getGvBinding();
        Group.DataBean.GroupListBean group = list.get(position);
        gvBinding.setGroup(group);
        BitmapPool bitmapPool = Glide.get(context).getBitmapPool();
        Glide.with(context).load(group.icon).bitmapTransform(new RoundedCornersTransformation(bitmapPool, 5, 0)).into(gvBinding.iv);
        gvBinding.executePendingBindings();
    }

    class ViewHolder extends MyBaseAdapter.BaseHolder {

        private ActivityInfoItemvpVpGvBinding gvBinding;

        public ViewHolder(View convertView) {
            gvBinding  = DataBindingUtil.bind(convertView);
        }

        public ActivityInfoItemvpVpGvBinding getGvBinding() {
            return gvBinding;
        }
    }
}
